package cn.itcast.erp.exception;

import cn.itcast.erp.controller.DepController;
import cn.itcast.erp.entity.utils.AjaxResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.net.BindException;
import java.sql.SQLIntegrityConstraintViolationException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/*
* 去重异常处理
* @author 罗宇航, 崔凯铭
* @date 2019.6.6
* */
@RestControllerAdvice(basePackageClasses = DepController.class)
public class SqlException {

    @ExceptionHandler(SQLIntegrityConstraintViolationException.class)
    public AjaxResult error(SQLIntegrityConstraintViolationException ex){

        ex.printStackTrace();
        AjaxResult ar = new AjaxResult();
        ar.setMsg("名称已存在");
        return ar;
    }

}
